package org.com.gamemall.Utity;

import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import dev.langchain4j.model.chat.ChatModel;
import dev.langchain4j.service.AiServices;
import org.com.gamemall.Service.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class Aifactory {
    @Autowired
     ChatModel chatModel;

    @Bean
    public ChatService chatService() {
        ChatMemory chatMemory = MessageWindowChatMemory.withMaxMessages(16);
        return AiServices.builder(ChatService.class)
                .chatModel(chatModel)
                .chatMemory(chatMemory)
                .build();
    }
}
